\documentclass[11pt]{amsart}
\usepackage{xcolor}
\usepackage{geometry}                % See geometry.pdf to learn the layout options. There are lots.
\geometry{a4paper}                   % ... or a4paper or a5paper or ... 
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{epstopdf}
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}
\newcommand{\myvec}[1]{\overrightarrow{#1}}
\newcommand{\mygrad}{\vec{\nabla}}
\newcommand{\mymat}[1]{\mathbf{#1}}
\newcommand{\mytrn}[1]{{\!\!~^{\mathsf{t}}{#1}}}

\title{Technical Details}

\begin{document}
\maketitle


\section{Non uniform differential approximations}

Let $f(x)$ be a function estimated by
\[
	f(x) = f_0 + ax + b x^2
\]
with
\[
	f_\pm = f_0 \pm a \delta_\pm + b \delta_\pm^2
\]
and the conditions
\[
	\delta_\pm > 0 %,\; \delta_- + \delta_+ > 0.
\]
Then
\[
\begin{array}{rcl}
	a & = &
	\dfrac{1}{\delta_-^2\delta_+ + \delta_+^2\delta_-}
	\left[ 
	   \delta_-^2\left(f_+ - f_0 \right)
	 - \delta_+^2\left(f_- - f_0 \right)
	\right] \\
	\\
	& = & \dfrac{1}{\delta_- + \delta_+} 
	\left[
	 \dfrac{\delta_-}{\delta_+} \left(f_+ - f_0 \right)
	-\dfrac{\delta_+}{\delta_-} \left(f_- - f_0 \right)
	\right] \\
	\\
	& = & \dfrac{1}{\delta_- + \delta_+} 
	\left[
	\dfrac{\delta_-}{\delta_+} f_+
	+\left(\dfrac{\delta_+}{\delta_-} - \dfrac{\delta_-}{\delta_+}\right) f_0
	-\dfrac{\delta_+}{\delta_-} f_-
	\right]\\
\end{array}
\]
and
\[
\begin{array}{rcl}
	b & = & \dfrac{1}{\delta_-^2\delta_+ + \delta_+^2\delta_-}
	\left[ 
	\delta_- \left(f_+ - f_0\right) + \delta_+ \left(f_-f_0\right)
	\right]
\\
\end{array}
\]

\section{Geometrical Curvatures on an arc}
Let $A$ and $B$ be two points of an arc with their tangent unit vector $\vec{\tau}_A$
and $\vec{\tau}_B$ and their real curvatures $C_A$ and $C_B$, producing
some normal gradients $g_A$ and $g_B$.Let $Q$ be a point of that arc: 
how can we evaluate $g_Q$ ?\\
Let us introduce the first order position of $Q$ on the arc
\[
	\mu = \dfrac{\myvec{AQ}\myvec{AB}}{|AB|^2}.
\]
The first order gradient is
\[
	\tilde{g}_Q = g_A + \mu (g_B-g_A).
\]
The geometrical curvature of $Q$ is
\[
	\hat{C}_Q = \dfrac{2}{|AB|} \dfrac{\det(\myvec{AQ},\myvec{QB})}{|AQ||QB|}
\]
with the limiting cases
\[
	\begin{array}{rcl}
	\hat{C}_A & = & \dfrac{2}{|AB|^2}\det(\vec{\tau}_A,\myvec{AB}) \\
	\hat{C}_B & = & \dfrac{2}{|AB|^2}\det(\myvec{AB},\vec{\tau}_B). \\
	\end{array}
\]

\section{Gradient Propagation}
\subsection{Setup}
Let's assume we know the gradient pressure at point $A$ and $B$, and
the tangential gradient pressure at point $Q$.
We also know the tangential and normal vectors at this three points
Let us assume that
\[
	\mygrad P = \alpha \vec{\tau} + \beta \vec{n}.
\]
So
\[
	P_Q - P_A = \int_A^Q \mygrad P \; d\vec{r}
\]
and
\[
	P_B - P_Q = \int_Q^B  \mygrad P \; d\vec{r}
\]
To integrate the gradient pressure, we need a path from $A$ to $B$ including $Q$.
Let us assume that the arc
\[
		\vec{r}(\mu), \;\mu\in[0;1]
\]
is the path from $A$ to $B$ such that $\vec{r}(0)=\vec{A}$, $\vec{r}(1)=\vec{B}$, and that $\vec{r}(\lambda)=\vec{Q}$.
Then
\[
	P_Q - P_A = \int_0^\lambda \mygrad P \; \dot{\vec{r}}(\mu) d\mu
\]
and
\[
	P_Q - P_B = \int_1^\lambda \mygrad P \; \dot{\vec{r}}(\mu) d\mu
\]
\subsection{Gradient Expression}
\subsubsection{Degrees Of Freedom}
Let us determine the minimum degrees of freedom requested for $\mygrad P$.
It is know at $A$ and $B$ (+4 scalar values).
The tangential part is known at $Q$ (+1).
Then we must respect the pressure jumps (+2).
We need at least 7 degrees of freedom.
By symetry, $\alpha$ and $\beta$ are some third order polynomials in $\mu$.
\[
	\left\lbrace
	\begin{array}{rcl}
		\alpha(\mu) & = & \alpha_A + \mu X_1 + \mu^2 X_2 + \mu^3 X_3\\
		\beta(\mu)  & = & \beta_A  + \mu X_4 + \mu^2 X_5 + \mu^3 X_6\\
	\end{array}
	\right.
\]
while the Frenet basis is supposed to vary linearly from $A$ to $Q$ and from $Q$ to $B$:
\[
	\vec{\tau}(\mu\in[0:\lambda]) =
	\begin{pmatrix}
	 \cos \theta(\mu)\cr
	 \sin \theta(\mu)
	 \end{pmatrix},\;
	 \vec{n}(\mu\in[0:\lambda]) =
	\begin{pmatrix}
	 -\sin \theta(\mu)\cr
	 \cos \theta(\mu)
	 \end{pmatrix}
\]
with 
\[
	\theta(\mu) = \theta_A + \frac{\mu}{\lambda} \delta\theta
\]
and
\[
	\vec{\tau}(\mu\in[\lambda:1]) =
	\begin{pmatrix}
	 \cos \theta'(\mu)\cr
	 \sin \theta'(\mu)
	 \end{pmatrix},\;
	 \vec{n}(\mu\in[\lambda:1]) =
	\begin{pmatrix}
	 -\sin \theta'(\mu)\cr
	 \cos \theta'(\mu)
	 \end{pmatrix}
\]
with 
\[
	\theta'(\mu) = \theta_Q + \dfrac{\mu-\lambda}{1-\lambda} \delta\theta'.
\]

\subsubsection{Constraints}
With $\vec{X}=\left(X_1,\cdots,X_8\right)$, the constraints are:
\begin{itemize}
\item
\[
	\vec{K}_\alpha\vec{X} = \alpha_B-\alpha_A, \; \vec{K}_\alpha= \mytrn{\begin{pmatrix} 1 & 0 & 1 & 0 & 1 & 0\cr \end{pmatrix}}
\]
\item
\[
	\vec{K}_\beta\vec{X} = \beta_B-\beta_A, \; \vec{K}_\beta= \mytrn{\begin{pmatrix} 0 & 1 & 0 & 1 & 0 & 1\cr \end{pmatrix}}
\]
\item
\[
	\vec{K}_\lambda\vec{X} = \alpha_Q-\alpha_A, \;\vec{K}_\lambda= \mytrn{\begin{pmatrix} \lambda & 0 & \lambda^2 & 0 & \lambda^3 & 0\cr \end{pmatrix}}
 \]
 \item
 \[
 P_Q-P_A = \alpha_A I_0 + \beta_A J_0 + \vec{K}\vec{X},
 \;\vec{K} = \mytrn{\begin{pmatrix} I_1 & J_1 & I_2 & J_2 & I_3 & J_3\cr \end{pmatrix}}
 \]
 with
 \[
 	I_\nu = \int_0^\lambda \mu^\nu\, \vec{\tau}(\mu)\dot{\vec{r}}(\mu) d\mu,\;\;
 	J_\nu = \int_0^\lambda \mu^\nu\, \vec{n}(\mu)\dot{\vec{r}}(\mu) d\mu,
 \]
 \item
 \[
 P_Q-P_B = \alpha_B {I_0}' + \beta_B {J_0}' + \vec{K}'\vec{X},
 \;\vec{K}' = \mytrn{\begin{pmatrix} {I_1}' & {J_1}' & {I_2}' & {J_2}' & {I_3}' & {J_3}'\cr \end{pmatrix}}
 \]
 with
 \[
 	{I_\nu}' = \int_1^\lambda \mu^\nu\, \vec{\tau}(\mu)\dot{\vec{r}}(\mu) d\mu,\;\;
 	{J_\nu}' = \int_1^\lambda \mu^\nu\, \vec{n}(\mu)\dot{\vec{r}}(\mu) d\mu,
 \]
 \end{itemize}

\subsubsection{Minimization}
We assume that the gradient reconstruction respect the least variation principle,
so that we want to minimize
\[
	\int_0^1 \left[ \left(\partial_\mu\alpha\right)^2 + \left(\partial_\mu\beta\right)^2\right] \; d\mu
\]
which is equivalent to minimize
\[
	E(\vec{X}) = \frac{1}{2} \mytrn{\vec{X}} \mymat{M} \vec{X}
\]
with
\[\mymat{M}=\begin{pmatrix}30 & 0 & 30 & 0 & 30 & 0\cr 0 & 30 & 0 & 30 & 0 & 30\cr 30 & 0 & 40 & 0 & 45 & 0\cr 0 & 30 & 0 & 40 & 0 & 45\cr 30 & 0 & 45 & 0 & 54 & 0\cr 0 & 30 & 0 & 45 & 0 & 54\end{pmatrix}.
\]
We define the Lagrangian of this system as
\[
	L(\vec{X}) = E(\vec{X}) - \mytrn{\vec{\Lambda}} \left( \mymat{K}\vec{X} - \vec{Z}\right)
\]
with
\[
	\mymat{K} =
	\begin{pmatrix}
	1 & 0 & 1 & 0 & 1 & 0\cr
	0 & 1 & 0 & 1 & 0 & 1\cr
	\lambda & 0 & \lambda^2 & 0 & \lambda^3 & 0\cr
	I_1 & J_1 & I_2 & J_2 & I_3 & J_3\cr
	{I_1}' & {J_1}' & {I_2}' & {J_2}' & {I_3}' & {J_3}'\cr
	\end{pmatrix},\;\;
	\vec{Z} =
	\begin{pmatrix}
	\alpha_B - \alpha_A \cr
	\beta_B  - \beta_A  \cr
	\alpha_Q - \alpha_A \cr
	P_Q-P_A -( \alpha_A  I_0    + \beta_A J_0)\cr
	P_Q-P_B -( \alpha_B {I_0}'  + \beta_B {J_0}')\cr \cr
	\end{pmatrix}
\]
The constraint optimum is defined by
\[
	\mymat{M}\vec{X} = \mytrn{\mymat{K}} \vec{\Lambda}
\]
so that with
\[
	\mymat{J} = \mymat{M}^{-1}, \vec{X} = \mymat{J}\mytrn{\mymat{K}} \vec{\Lambda}.
\]
The Lagrange multipliers are solution of
\[
	 \mymat{K}\mymat{J}\mytrn{\mymat{K}}\vec{\Lambda} = \vec{Z}
\]
and
\[
	\beta_Q = \beta_A + \lambda X_4 + \lambda^2 X_5 + \lambda^3 X_6
\]

\section{Differential Arc}
Let $\vec{r}_0$ and $\vec{r}_1$ be two points of a curve
with some respective tangent vector $\vec{\tau}_0$ and $\vec{\tau}_1$, and their
respective curvature $C_0$ and $C_1$.

We assume that $\vec{r}(\mu)$ represent the arc between those two points:
\[
	\vec{r}(\mu) = \vec{r}_0 + \mu \vec{a} + \mu^2 \vec{b} + \mu^3 \vec{c}
\]
We obtain
\[
	\dot{\vec{r}}(\mu) = \vec{a} + 2 \mu \vec{b} + 3 \mu^2 \vec{c}
\]
and
\[
	\ddot{\vec{r}}(\mu) = 2\vec{b} + 6 \mu \vec{c}.
\]
The curvature is
\[
	C(\mu) = \dfrac{\det\left(\dot{\vec{r}},\ddot{\vec{r}}\right)}{\left|\dot{\vec{r}}\right|^3}
\]
so that
\[
	C(\mu) = \dfrac{2}{\left|\vec{a} + 2 \mu \vec{b} + 3 \mu^2 \vec{c}\right|^3}
	\left[
	\det\left(\vec{a},\vec{b}\right)
	+3\mu\det\left(\vec{a},\vec{c}\right)
	+3\mu^2\det\left(\vec{b},\vec{c}\right)
	\right].
\]
We need a third degree polynomial, otherwise we can only represent
the arcs with the same sign of curvature.
We must solve the following equations
\[
	\left\lbrace
	\begin{array}{rcl}
	\vec{\delta} & = & \vec{a} + \vec{b} + \vec{c}\\
	0 & = & \left|\vec{a}\right| - \vec{a}\vec{\tau}_0\\
	0 & = & \left|\vec{a}+2\vec{b}+3\vec{c}\right| - \left(\vec{a}+2\vec{b}+3\vec{c}\right)\vec{\tau}_1\\
	0 & = & \dfrac{C_0}{2} \left|\vec{a}\right|^3 - \det\left(\vec{a},\vec{b}\right)\\
	\\
	0 & = & \dfrac{C_1}{2} \left|\vec{a}+2\vec{b}+3\vec{c}\right|^3 
	- \left[\det\left(\vec{a},\vec{b}\right)+3\det\left(\vec{a},\vec{c}\right)+3\det\left(\vec{b},\vec{c}\right)\right]
	\end{array}
	\right.
\]
Using $\vec{c} = \vec{\delta} - \left(\vec{a}+\vec{b}\right)$, so that
$\vec{a}+2\vec{b}+3\vec{c}=3\vec{\delta}-(2\vec{a}+\vec{b})$
and normalizing the equations we obtain
\[
	\left\lbrace
	\begin{array}{rcl}
	0 & = &  1-\dfrac{\vec{a}\vec{\tau}_0}{\left|\vec{a}\right|}\\
	\\
	0 & = & 1 
	- \dfrac{\left( 3\vec{\delta}-(2\vec{a}+\vec{b})\right)\vec{\tau}_1}{\left|3\vec{\delta}-(2\vec{a}+\vec{b})\right|}
	\\
	\\
	0 & = & \delta\left( \dfrac{C_0}{2} -  \dfrac{\det\left(\vec{a},\vec{b}\right)}{\left|\vec{a}\right|^3 }\right)\\
	\\
	0 & = & \delta\left( \dfrac{C_1}{2}
	 - \dfrac{\left[
	 \det\left(\vec{a},\vec{b}\right) + 3\det\left(\vec{a},\vec{\delta}\right) + 3\det\left(\vec{b},\vec{\delta}\right)
	  \right]}{\left|3\vec{\delta}-(2\vec{a}+\vec{b})\right|^3}\right)\\
	\end{array}
	\right.
\]

\section{Bezier Curve}
Let $\vec{P}_0,\vec{P}_1,\vec{P}_2,\vec{P}_3$
be the four control points of a Bezier curve
\[
	P(t) = \sum_{i=0}^4 B_i(t) \vec{P}_i
\]
where the $B_i$ are the Bernstein polynomials
\[
	\begin{array}{rcl|rcl|rcl}
	B_0(t) & = & (1-t)^3  & \dot{B}_0(t) & = & -3(1-t)^2     & \ddot{B}_0(t) & = & 6(1-t)\\
 	B_1(t) & = & 3(1-t)^2t & \dot{B}_1(t) & = &  3(3t^2-4t+1) & \ddot{B}_1(t) & = & 6(3t-2)\\
	B_2(t) & = & 3(1-t)t^2 & \dot{B}_2(t) & = &  3(2t-3t^2)   & \ddot{B}_2(t) & = & 6(1-3t)\\
	B_3(t) & = & t^3      & \dot{B}_3(t) & = &  3t^2         & \ddot{B}_3(t) & = & 6t    \\
	\end{array} 
\]
With
\[
	\dot{P}(t) = \sum_{i=0}^4 B_i(t) \vec{P}_i
\]
we have
\[
\begin{array}{rcl}
	\dot{P}(0) & = & 3\vec{P}_1 - 3\vec{P}_0 \\
	\dot{P}(1) & = & 3\vec{P}_3 - 3\vec{P}_2 \\
\end{array}
\]
and
\[
	\begin{array}{rcl}
	\ddot{P}(0) & = & 6\vec{P}_0 - 12 \vec{P}_1 + 6\vec{P}_2\\
	\ddot{P}(1) & = & 6\vec{P}_1 - 12 \vec{P}_2 + 6\vec{P}_3\\
	\end{array}
\]
We have
\[
	C_0 = \dfrac{\det(\dot{P}(0),\ddot{P}(0))}{\left|\dot{P}(0)\right|^3} 
	= \dfrac{2}{3} \dfrac{\det(\vec{P}_1 - \vec{P}_0,\vec{P}_2 - \vec{P}_1)}{\left|\vec{P}_1 - \vec{P}_0\right|^3}
\]
and
\[
	C_1 = \dfrac{\det(\dot{P}(1),\ddot{P}(1))}{\left|\dot{P}(1)\right|^3} 
	= \dfrac{2}{3} \dfrac{\det(\vec{P}_3 - \vec{P}_2,\vec{P}_1 - \vec{P}_2)}{\left|\vec{P}_3 - \vec{P}_2\right|^3}
\]


\end{document}


